package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GoodsEvaluate;
import com.ruoyi.system.service.IGoodsEvaluateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商品评价管理Controller
 * 
 * @author 墨染
 * @date 2024-09-28
 */
@RestController
@RequestMapping("/system/goodsEvaluate")
public class GoodsEvaluateController extends BaseController
{
    @Autowired
    private IGoodsEvaluateService goodsEvaluateService;

    /**
     * 查询商品评价管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:goodsEvaluate:list')")
    @GetMapping("/list")
    public TableDataInfo list(GoodsEvaluate goodsEvaluate)
    {
        startPage();
        List<GoodsEvaluate> list = goodsEvaluateService.selectGoodsEvaluateList(goodsEvaluate);
        return getDataTable(list);
    }

    /**
     * 导出商品评价管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:goodsEvaluate:export')")
    @Log(title = "商品评价管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GoodsEvaluate goodsEvaluate)
    {
        List<GoodsEvaluate> list = goodsEvaluateService.selectGoodsEvaluateList(goodsEvaluate);
        ExcelUtil<GoodsEvaluate> util = new ExcelUtil<GoodsEvaluate>(GoodsEvaluate.class);
        util.exportExcel(response, list, "商品评价管理数据");
    }

    /**
     * 获取商品评价管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:goodsEvaluate:query')")
    @GetMapping(value = "/{evaluateId}")
    public AjaxResult getInfo(@PathVariable("evaluateId") Long evaluateId)
    {
        return success(goodsEvaluateService.selectGoodsEvaluateByEvaluateId(evaluateId));
    }

    /**
     * 新增商品评价管理
     */
    @PreAuthorize("@ss.hasPermi('system:goodsEvaluate:add')")
    @Log(title = "商品评价管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoodsEvaluate goodsEvaluate)
    {
        return toAjax(goodsEvaluateService.insertGoodsEvaluate(goodsEvaluate));
    }

    /**
     * 修改商品评价管理
     */
    @PreAuthorize("@ss.hasPermi('system:goodsEvaluate:edit')")
    @Log(title = "商品评价管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GoodsEvaluate goodsEvaluate)
    {
        return toAjax(goodsEvaluateService.updateGoodsEvaluate(goodsEvaluate));
    }

    /**
     * 删除商品评价管理
     */
    @PreAuthorize("@ss.hasPermi('system:goodsEvaluate:remove')")
    @Log(title = "商品评价管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evaluateIds}")
    public AjaxResult remove(@PathVariable Long[] evaluateIds)
    {
        return toAjax(goodsEvaluateService.deleteGoodsEvaluateByEvaluateIds(evaluateIds));
    }
}
